﻿/// <reference path="jquery-1.4.1-vsdoc.js" />

$(function () {
    $('#Province').change(function () {
        $.ajax({
            type: "POST",
            url: "/Address/AjaxGetAddressByID",
            data: "codeID=" + $(this).val(),
            success: function (json) {
                $("#City option[value!='']").remove();
                for (var item in json) {
                    $("#City").append("<option value='" + json[item].Value + "'>" + json[item].Text + "</option>");
                }
                $("#City").hide();
                $("#City").show();
                $("#District option[value!='']").remove();
                $("#District").hide();
            }
        });
    })

    $('#City').change(function () {
        $.ajax({
            type: "POST",
            url: "/Address/AjaxGetAddressByID",
            data: "codeID=" + $(this).val(),
            success: function (json) {
                $("#District option[value!='']").remove();
                for (var item in json) {
                    $("#District").append("<option value='" + json[item].Value + "'>" + json[item].Text + "</option>");
                }
                $("#District").hide();
                $("#District").show();
            }
        });
    })
})